<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<!--<script src="./aes_iv.js"></script>-->
<script src="./aes_pwd.js"></script>
<body>
</body>
<script>
    /**
     * @author liu
     * @date 2019/7/10/010
     * @Description: aes_iv
    */

    // var key = CryptoJS.enc.Utf8.parse("1234567891234567"); //十六位十六进制数作为秘钥
    // var iv  = CryptoJS.enc.Utf8.parse('1234567891234567'); //十六位十六进制数作为秘钥偏移量
    // function Encrypt(word){
    //     srcs = CryptoJS.enc.Utf8.parse(word);
    //     var encrypted = CryptoJS.AES.encrypt(srcs, key, { iv: iv,mode:CryptoJS.mode.CBC,padding: CryptoJS.pad.Pkcs7});
    //     return encrypted.ciphertext.toString().toUpperCase();
    // }
    //
    // function Decrypt(word){
    //     var encryptedHexStr = CryptoJS.enc.Hex.parse(word);
    //     var srcs = CryptoJS.enc.Base64.stringify(encryptedHexStr);
    //     var decrypt = CryptoJS.AES.decrypt(srcs, key, { iv: iv,mode:CryptoJS.mode.CBC,padding: CryptoJS.pad.Pkcs7});
    //     var decryptedStr = decrypt.toString(CryptoJS.enc.Utf8);
    //     return decryptedStr.toString();
    // }
    // var mm = Encrypt('123456')
    // console.log(mm);
    // var jm = Decrypt(mm);
    // console.log(jm)


    /**
     * @author liu
     * @date 2019/7/10/010
     * @Description:  aes_pwd
    */

    var pwd="11233444";//秘钥
    // 这个随机的
    function Encrypt(word){
        return CryptoJS.AES.encrypt(word,pwd).toString();
    }

    function Decrypt(word){
        return CryptoJS.AES.decrypt(word,pwd).toString(CryptoJS.enc.Utf8);
    }

    var mm = Encrypt('18612345678');
    console.log(mm)
    var jm = Decrypt(mm);
    console.log(jm)

</script>
</html>